<?php
require_once APP_ROOT.'view/common/layout.view.php';
require_once APP_ROOT.'view/common/layout.formview.php';
require_once APP_ROOT.'model/common/session.php';
require_once 'include/inc.config.php';
require_once APP_ROOT.'model/common/article.php';
require_once APP_ROOT . "model/common/parameters.php";
require_once APP_ROOT . "model/common/site.php";
require_once APP_ROOT.'model/common/video.php';
require_once APP_ROOT.'model/common/statdivisions.php';
require_once APP_ROOT.'model/common/statteams.php';
require_once APP_ROOT.'model/common/statscores.php';


class RightViewHelper  {
       var $view;
       var $Template;

	function RightViewHelper(&$myview) {
        $this->view =& $myview;
        $this->Template =& $myview->Template;
    }

    function prepare() {

		$this->Template->set('SITE_CSS',Site::getSiteTemplateCSS());
		$this->Template->set('SITE_BASE',Site::getSiteTemplateBase());
		$this->Template->set('SITE_TITLE',Site::getTitle());

		$docbase="http://".$_SERVER['HTTP_HOST'];
		$this->Template->set('docbase',$docbase);
		$this->Template->set('rightmenu',' ');
		$this->Template->set('app_name',APP_NAME);
        $this->Template->set('skip_left_menu',true);

		$list=&User::getFrontpageAuthors();
        $this->Template->setChildDataSource('frontauthors',$list);

        //right menu  Above columnists
        $rightmenu_above =& LeftMenuModel::getLeftMenuList(2);
        $this->Template->setChildDataSource('rightmenu_above',$rightmenu_above);

        //right menu  Under columnists
        $rightmenu_under =& LeftMenuModel::getLeftMenuList(3);
        $this->Template->setChildDataSource('rightmenu_under',$rightmenu_under);

        $others =& User::getNotFrontpageAuthors();
        //print_r( $others );
		//$authors =& $this->Template->getChild('authors');
		//$this->Template->setChildDataSource('otherauthors',$list);
		//$authors->setChoices($others);
		$this->Template->setChildDataSource('otherauthors',$others);

		if(Session::isLogin()){
			if(defined('SID')&&(!isset($_COOKIE[session_name()])))
    	 		$this->Template->set('SID','&'.SID);
		}

        $banner =& LogoBannersModel::getBanner('RIGHT');
        $this->Template->set($banner[0], $banner[1]);
        $this->Template->set('RIGHTbanner_link', $banner[2]);
        $this->Template->set('RIGHTbanner_alt', $banner[3]);
        $url = $banner[1];   // banner url
        $target_url = $banner[2];   // target url

        /*
		$record =& LogoBannersModel::getInfo(4);
		if (is_null($record) ) {
			$url = '/images/forum_ad.gif';
		} else {
            		$url = $record->get('url');
		}
		*/
        	$this->Template->set('url_banner',$url);
            $this->Template->set('forum_url',$target_url);
        	//$this->Template->set('forum_url',FORUM);


		$teamStatsShow = Parameters::getTeamStatsStatus();
		$videoShow = Parameters::getVideoStatus();

		if ($teamStatsShow) $this->Template->set('teamStatsShow', 1);
		if ($videoShow) $this->Template->set('videoShow', 1);


  		// determine if Standings block exists
  		$standingsItem =& $this->Template->findChild('standings');
        if ($standingsItem) {
			// populate Standings block
  			$divisionID  = 0;
			//$divisionID = $_REQUEST["divisionID"];
			//if ($request->hasParameter('divisionID')
				//$divisionID = $request->getParameter('divisionID');
			if (array_key_exists('divisionID', $_REQUEST))
   				$divisionID = $_REQUEST['divisionID'];

  			if (!$divisionID) $divisionID = Division::getFirstDivisionID();

			$divisions =& Division::getDivisionsPublic($divisionID);
  			$this->Template->setChildDataSource('divisions',$divisions);

  			$teams =& StatTeam::getTeamsPublic($divisionID);
  			$this->Template->setChildDataSource('standings',$teams);

  			$record =& Division::getRecord($divisionID);
  			if ($record) {
  				$divisionName = $record->get('divisionName');
  				$leagueName = $record->get('leagueName');
  				if ($leagueName) $divisionName = $leagueName.':'.$divisionName;
  				$this->Template->set('divisionName', $divisionName);
  			}
  		}




    }
}

class LayoutRightView extends LayoutView {
	function LayoutRightView($TemplateFile) {
        parent :: LayoutView($TemplateFile);
    }

    function prepare() {
    	parent::prepare();
    	$helper =& new RightViewHelper($this);
    	$helper->prepare();
    }
}

class LayoutFormRightView extends LayoutFormView {
	function LayoutFromRightView($TemplateFile) {
        parent :: LayoutFormView($TemplateFile);
    }

	function prepare() {
		parent::prepare();

	   	$helper =& new RightViewHelper($this);
    	$helper->prepare();
 	}
}









?>
